package com.igeekhome.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.igeekhome.biz.IAttendanceStatisticsService;
import com.igeekhome.biz.IViewStatisticsService;
import com.igeekhome.biz.IWorkQualityStatisticsService;
import com.igeekhome.biz.IWorkloadStatisticsService;
import com.igeekhome.pojo.ViewStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-03-16
 */
@Controller

@RequestMapping("/user")
public class UserController {

    @Autowired
    private IWorkQualityStatisticsService iWorkQualityStatisticsService;

    @Autowired
    private IWorkloadStatisticsService iWorkloadStatisticsService;

    @Autowired
    private IViewStatisticsService iViewStatisticsService;

    @Autowired
    private IAttendanceStatisticsService iAttendanceStatisticsService;
    //  数据总览
    @RequestMapping("/zonglan")
    public String zonglan(Model model){
        QueryWrapper qw =new QueryWrapper();
        //工作质量
        int sumeffsess=iWorkQualityStatisticsService.getSumeffsess(qw);
        int sumresolve=iWorkQualityStatisticsService.getSumresolve(qw);
        int sumnosolve=iWorkQualityStatisticsService.getSumunsolve(qw);
        int sumgood=iWorkQualityStatisticsService.getSumgood(qw);
        int summedium=iWorkQualityStatisticsService.getSummedium(qw);
        int sumbad=iWorkQualityStatisticsService.getSumbad(qw);
        int sumno=iWorkQualityStatisticsService.getSumno(qw);
        //最大个人工作量
        int toMe=iWorkloadStatisticsService.getToMe(qw);
        int toSeCount=iWorkloadStatisticsService.getToSeCount(qw);
        int toEff=iWorkloadStatisticsService.getToEff(qw);
        int toEnd=iWorkloadStatisticsService.getToEnd(qw);
        int toSeTime=iWorkloadStatisticsService.getToSeTime(qw);
        // 各平台来源
        qw.eq("viewType","微信小程序");
        ViewStatistics weixin=iViewStatisticsService.getOne(qw);
        model.addAttribute("weixin",weixin);

        QueryWrapper qw1 =new QueryWrapper();
        qw1.eq("viewType","手机App");
        ViewStatistics phoneapp=iViewStatisticsService.getOne(qw1);
        model.addAttribute("phoneapp",phoneapp);

        QueryWrapper qw2 =new QueryWrapper();
        qw2.eq("viewType","网页");
        ViewStatistics wangye=iViewStatisticsService.getOne(qw2);
        model.addAttribute("wangye",wangye);

        QueryWrapper qw3 =new QueryWrapper();
        qw3.eq("viewType","微信公众号");
        ViewStatistics weixingz=iViewStatisticsService.getOne(qw3);
        model.addAttribute("weixingz",weixingz);

        QueryWrapper qw4 =new QueryWrapper();
        qw4.eq("viewType","微博");
        ViewStatistics weibo=iViewStatisticsService.getOne(qw4);
        model.addAttribute("weibo",weibo);

        QueryWrapper qw5 =new QueryWrapper();
        qw5.eq("viewType","头条号");
        ViewStatistics toutiao=iViewStatisticsService.getOne(qw5);
        model.addAttribute("toutiao",toutiao);

        //考勤统计
        QueryWrapper qw6 =new QueryWrapper();
        int maxLogin=iAttendanceStatisticsService.getLogin(qw6);
        int maxFree=iAttendanceStatisticsService.getFree(qw6);
        int maxBusy=iAttendanceStatisticsService.getBusy(qw6);
        int maxOnline=iAttendanceStatisticsService.getOnline(qw6);
        int maxOffline=iAttendanceStatisticsService.getOffice(qw6);
        //考勤model
        model.addAttribute("maxLogin",maxLogin);
        model.addAttribute("maxFree",maxFree);
        model.addAttribute("maxBusy",maxBusy);
        model.addAttribute("maxOnline",maxOnline);
        model.addAttribute("maxOffline",maxOffline);






        model.addAttribute("sumeffsess",sumeffsess);
        model.addAttribute("sumresolve",sumresolve);
        model.addAttribute("sumnosolve",sumnosolve);
        model.addAttribute("sumgood",sumgood);
        model.addAttribute("summedium",summedium);
        model.addAttribute("sumbad",sumbad);
        model.addAttribute("sumno",sumno);

        model.addAttribute("toMe",toMe);
        model.addAttribute("toSeCount",toSeCount);
        model.addAttribute("toEff",toEff);
        model.addAttribute("toEnd",toEnd);
        model.addAttribute("toSeTime",toSeTime);
//xxxMapper.selectOne(QueryWrapper(...).orderByDesc("排序字段名").last("limit 1"));
        return "zonglan";
    }
}

